﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace FirstGame
{
    public abstract class VisibleGameEntity : GameEntity
    {
        protected List<My2Dsprite> sprites;

        public List<My2Dsprite> Sprites
        {
            get { return sprites; }
            set { sprites = value; }
        }
        protected int _nSprite;

        public int NSprite
        {
            get { return _nSprite; }
            set { _nSprite = value; }
        }

        protected Vector2 _TopLeft;

        public Vector2 TopLeft
        {
            get { return _TopLeft; }
            set { _TopLeft = value; }
        }
        protected Vector2 _Size;

        public Vector2 Size
        {
            get { return _Size; }
            set { _Size = value; }
        }

        virtual public void Update(GameTime gameTime, InputSystem input)
        {
            for (int i = 0; i < _nSprite; i++)
                sprites[i].Update(gameTime);
        }

        virtual public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            for (int i = 0; i < _nSprite; i++)
                sprites[i].Draw(gameTime, spriteBatch, 200);
        }

        virtual public bool IsClicked(Vector2 point)
        {
            if ((point.X >= _TopLeft.X) &&
                (point.X <= _TopLeft.X + _Size.X) &&
                (point.Y >= _TopLeft.Y) &&
                (point.Y <= _TopLeft.Y + _Size.Y))
                return true;
            return false;
        }
    }
}
